package Dao;

import eneity.Message;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class MessageDao {
    private static Connection connection = null;
    private static PreparedStatement statement = null;
    private static ResultSet resultSet = null;

    public static int insert(Message message) throws SQLException {
        connection = DBUtil.getConnection();
        String sql = "insert into message values(?,?,?)";
        statement = connection.prepareStatement(sql);
        statement.setString(1, message.getUsername());
        statement.setString(2,message.getDate());
        statement.setString(3, message.getMessage());

        int ret = statement.executeUpdate();
        return ret;
    }
}
